{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "44bf287d",
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch\n",
    "import torch.nn as nn"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "e6c99faf",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[0.5643, 0.4795]])\n",
      "graph(%self : __torch__.___torch_mangle_78.SecureModel,\n",
      "      %x.1 : Tensor):\n",
      "  %13 : Tensor = prim::Constant[value=0.01 *  5.1170  3.8392 [ CPUFloatType{2} ]]() # :0:0\n",
      "  %11 : Tensor = prim::Constant[value=<Tensor>]() # :0:0\n",
      "  %6 : int = prim::Constant[value=1]()\n",
      "  %5 : Tensor = prim::Constant[value=<Tensor>]() # :0:0\n",
      "  %3 : Tensor = prim::Constant[value=<Tensor>]() # :0:0\n",
      "  %4 : Tensor = aten::matmul(%x.1, %3) # :0:0\n",
      "  %7 : Tensor = aten::add(%4, %5, %6) # :0:0\n",
      "  %x0.1 : Tensor = aten::relu(%7) # C:\\Users\\shenyc\\AppData\\Local\\Temp\\ipykernel_10616\\1765543665.py:8:12\n",
      "  %12 : Tensor = aten::matmul(%x0.1, %11) # :0:0\n",
      "  %15 : Tensor = aten::add(%12, %13, %6) # :0:0\n",
      "  %17 : Tensor = aten::sigmoid(%15) # C:\\Users\\shenyc\\AppData\\Local\\Temp\\ipykernel_10616\\1765543665.py:9:15\n",
      "  return (%17)\n",
      "\n",
      "def forward(self,\n",
      "    x: Tensor) -> Tensor:\n",
      "  _0 = torch.add(torch.matmul(x, CONSTANTS.c0), CONSTANTS.c1)\n",
      "  x0 = torch.relu(_0)\n",
      "  _1 = torch.add(torch.matmul(x0, CONSTANTS.c2), CONSTANTS.c3)\n",
      "  return torch.sigmoid(_1)\n",
      "\n"
     ]
    }
   ],
   "source": [
    "pt_file = \"secure_model.pt\"\n",
    "model: torch.nn.Module = torch.jit.load(pt_file)\n",
    "\n",
    "output = model(torch.rand(1, 10))\n",
    "print(output)\n",
    "\n",
    "\n",
    "# 打印模型图\n",
    "\n",
    "print(model.graph)\n",
    "\n",
    "\n",
    "# 打印模型代码\n",
    "print(model.code)\n",
    "\n",
    "\n",
    "# model.load_state_dict()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
